/*
* Copyright (C) 2006 Jordi Marquès Ferré
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file DUROTY.txt.
*
* Author: Jordi Marquès Ferré
* c/Mallorca 295 principal B 08037 Barcelona Spain
* Phone: +34 625397324
*/


package com.duroty.hibernate;


// Generated 14-sep-2006 11:28:32 by Hibernate Tools 3.1.0.beta5
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


/**
 * ContactList generated by hbm2java
 */
public class ContactList implements java.io.Serializable {
    // Fields    

    /**
     *
     */
    private static final long serialVersionUID = -8716286264598917501L;

    /**
     * DOCUMENT ME!
     */
    private int coliIdint;

    /**
     * DOCUMENT ME!
     */
    private Users users;

    /**
     * DOCUMENT ME!
     */
    private String coliName;

    /**
     * DOCUMENT ME!
     */
    private Set conColis = new HashSet(0);

    // Constructors

    /** default constructor */
    public ContactList() {
    }

    /** minimal constructor */
    public ContactList(int coliIdint, Users users, String coliName) {
        this.coliIdint = coliIdint;
        this.users = users;
        this.coliName = coliName;
    }

    /** full constructor */
    public ContactList(int coliIdint, Users users, String coliName, Set conColis) {
        this.coliIdint = coliIdint;
        this.users = users;
        this.coliName = coliName;
        this.conColis = conColis;
    }

    // Property accessors
    public int getColiIdint() {
        return this.coliIdint;
    }

    /**
     * DOCUMENT ME!
     *
     * @param coliIdint DOCUMENT ME!
     */
    public void setColiIdint(int coliIdint) {
        this.coliIdint = coliIdint;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Users getUsers() {
        return this.users;
    }

    /**
     * DOCUMENT ME!
     *
     * @param users DOCUMENT ME!
     */
    public void setUsers(Users users) {
        this.users = users;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getColiName() {
        return this.coliName;
    }

    /**
     * DOCUMENT ME!
     *
     * @param coliName DOCUMENT ME!
     */
    public void setColiName(String coliName) {
        this.coliName = coliName;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Set getConColis() {
        return this.conColis;
    }

    /**
     * DOCUMENT ME!
     *
     * @param conColis DOCUMENT ME!
     */
    public void setConColis(Set conColis) {
        this.conColis = conColis;
    }

    /**
     * DOCUMENT ME!
     *
     * @param conColi DOCUMENT ME!
     */
    public void addConColi(ConColi conColi) {
        if (!containsConColi(conColi)) {
            this.conColis.add(conColi);
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param obj DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public boolean containsConColi(ConColi obj) {
        Iterator it = this.conColis.iterator();

        while (it.hasNext()) {
            ConColi castObj = (ConColi) it.next();

            if ((castObj != null) && (obj != null) &&
                    (obj.getId().getContact().getConIdint() == castObj.getId()
                                                                          .getContact()
                                                                          .getConIdint())) {
                return true;
            }
        }

        return false;
    }
}
